package Controler.Matiere;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import JDBC.Matiere_Ajouter;
import Model.Matiere;

@WebServlet("/Matiere_AjouterController")

public class Matiere_AjouterController extends HttpServlet {
	
		private static final long serialVersionUID = 1L;
	       
	    public Matiere_AjouterController() 
	    {
	        super();
	    }
	    
	
		protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
		{
			String erreur = "";
			String JSPURL = "Vues/Matiere/vueGRP1_tableauMat.jsp";
			String libelle = request.getParameter("libelle");
			
			if(libelle.compareTo("") == 0)erreur = "Entrez un libelle";

			Matiere m = new Matiere();
			m.matiere = libelle;
			
			Matiere_Ajouter mat = new Matiere_Ajouter();
			mat.ajouter(m);
	
			request.setAttribute("matiere", m);
			RequestDispatcher rd = request.getRequestDispatcher(JSPURL+erreur);
			rd.forward(request, response);
	
		}

		protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
		{
			
		}

	}

	
	

